Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Raphael to work in pages with a Content Security Policy that disallows 'unsafe-eval'. #770

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SlexAxton
Copy link

Special case the Clone method to avoid using the Function constructor so Raphael works in pages with a Content Security Policy that disallows eval.

The input to this function is really only ever a function and and array, but unfortunately typeof or instanceof checks here won't work because the arrays will pass the same checks as the functions. Since the only special operation that's performed on the arrays is a join, I used that to detect whether to use a constructor or to fallback to a function literal.

The rest is just my editor stripping whitespace, which is probably a good thing anyways.

… so Raphael works in pages with a Content Security Policy that disallows eval.
@DmitryBaranovskiy
Copy link
Owner

How come typeof will yield the same result for array as for function? What about plain object {}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants